//
//  ViewController.m
//  18-SQLite
//
//  Created by dllo on 16/8/8.
//  Copyright © 2016年 ZHW. All rights reserved.
//

#import "ViewController.h"
#import "Student.h"
#import "SQLiteDataBaseManager.h"
@interface ViewController ()
@property (nonatomic, strong) SQLiteDataBaseManager *dataBaseManager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataBaseManager = [SQLiteDataBaseManager shareManager];
    // 注意: 使用SQLite需要引入libsqlite3.0.tbd
    // libsqlite3.0.tbd 和 libsqlite3.tbd区别
    // libsqlite3.0.tbd 是 libsqlite3.tbd的替身文件, 防止误删
    
}
- (IBAction)openSQLite:(id)sender {
    [_dataBaseManager openSQLite3];
}

- (IBAction)closeSQLite:(id)sender {
    [_dataBaseManager closeSQLite3];
}

- (IBAction)creatTable:(id)sender {
    [_dataBaseManager creatTable];
}

- (IBAction)insertData:(id)sender {
    Student *stu = [[Student alloc] init];
    stu.stu_id = 10;
    stu.stu_name = @"Mike";
    [_dataBaseManager insertStu:stu];
}

- (IBAction)updateData:(id)sender {
    [_dataBaseManager updateOldName:@"Mike" newName:@"Jack"];
}

- (IBAction)DeleteData:(id)sender {
    Student *stu = [[Student alloc] init];
//    [_dataBaseManager deleteStu:stu];
    [_dataBaseManager deleteAll];
}

- (IBAction)selectData:(id)sender {
    NSArray *array = [_dataBaseManager selectAll];
    NSLog(@"%@", array);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
